package org.quickstart.client.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import org.quickstart.model.Contact;

/**
 * @author Yoav Aharoni
 */
public class ContactUpdatedEvent extends GwtEvent<ContactUpdatedEvent.Handler> {
	public static final Type<Handler> TYPE = new Type<Handler>();

	private String oldName;
	private Contact contact;

	public ContactUpdatedEvent(String oldName, Contact contact) {
		this.oldName = oldName;
		this.contact = contact;
	}

	@Override
	public Type<Handler> getAssociatedType() {
		return TYPE;
	}

	public Contact getContact() {
		return contact;
	}

	public String getOldName() {
		return oldName;
	}

	@Override
	protected void dispatch(Handler handler) {
		handler.onContactUpdate(this);
	}

	public static interface Handler extends EventHandler {
		void onContactUpdate(ContactUpdatedEvent event);
	}
}
